<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.shsh.safemanage.action.WriteProblemAction"%>
<%@page import="com.shsh.safemanage.action.UserAction"%>
<%@page import="com.shsh.safemanage.action.ActionCreator"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.dao.TitlePostManageGroupDao"%>
<%@page import="com.shsh.safemanage.dao.UserDao"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.ProblemDao"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="com.shsh.safemanage.model.ProblemTransfer"%>
<%@page import="com.shsh.safemanage.model.ProblemTransferFeedback"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.model.JobPost"%>
<%@page import="com.shsh.safemanage.model.Role"%>
<%@page import="com.shsh.safemanage.model.Other"%>
<%@page import="com.shsh.safemanage.model.DefectType"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.util.Util"%>

<%
	session.removeAttribute(Constants.SESSION_ESCALATE_USER);
	session.removeAttribute(Constants.SESSION_MANAGE_GROUP_USER);
	session.removeAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);

String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
Long problemID = 0L;
try {
	problemID = new Long(problemIDStr);
} catch (Exception e) {
}

String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
Long transferID = null;
try {
	transferID = new Long(transferIDStr);
} catch (Exception e) {
}

String fromPage = request.getParameter(Constants.REQUEST_PARAMETER_FROM_PAGE);
String backPage = request.getContextPath()+"/other/other_browse.jsp";
if(Constants.FROM_PAGE_PROBLEMS_TOBE_PROCESSED.equals(fromPage)){
	backPage = request.getContextPath()+"/problems_tobe_processed.jsp";
} else if (Constants.FROM_PAGE_YIBAN_PAGE.equals(fromPage)){
	backPage = request.getContextPath()+"/problem_browse.jsp";
}

DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
ProblemDao problemDao = DaoCreator.createProblemDao();
UserDao userDao = DaoCreator.createUserDao();

TitlePostManageGroupDao titlePostManageGroupDao = DaoCreator.createTitlePostManageGroupDao();
WriteProblemAction writeProblemAction = ActionCreator.createWriteProblemAction();
UserAction userAction = ActionCreator.createUserAction();

Other problem = problemDao.getOtherByID(problemID);

List<ProblemTransferFeedback> feedbackList = problemDao.getProblemTransferFeedbackByProblemID(problemID);

User user = userDao.getUserByID(problem.getDefectWriteUserID());
JobPost post1 = titlePostManageGroupDao.getJobPostByID(user.getJobPost1ID());
JobPost post2 = titlePostManageGroupDao.getJobPostByID(user.getJobPost2ID());
JobPost post3 = titlePostManageGroupDao.getJobPostByID(user.getJobPost3ID());
Role theRole = userAction.getUserRole(request);

int role = writeProblemAction.calRole(post1, post2, post3, theRole);

List<DefectType> defectTypeList = problemDao.getDefectTypeList();
ProblemTransfer currentTransfer = problemDao.getProblemTransfer(problem.getWriteUserID(), problemID, user.getId());
if(currentTransfer != null){
	transferID = currentTransfer.getId();
}
%>
<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 其他报告浏览 
</div>

<div class="tt">《高桥石化公司其他报告》</div>
<div class="content">
	<table align="center" border="1" width="99%" cellpadding="0"
		cellspacing="0">
	<tr>
		<td class="td1" colspan="2">
			<span style="margin-left: 30px; font-weight: bold">流程跟踪：</span>
			<br />
			<span style="margin-left: 50px; color: red">
			<%=Util.formatDateTime(problem.getWriteTime())%> <%=problem.getWriteUserName()%> 填报问题
			</span>
			<%
			for (ProblemTransferFeedback feedback : feedbackList) {
			%>
			<br />
			<span style="margin-left: 50px; color: red">
			<%=Util.formatDateTime(feedback.getFeedbackTime())%>
			<%
			User theFeedbackUser = userDao.getUserByID(feedback.getUserID());
			%>
			<%=theFeedbackUser.getName()%>
			<%=feedback.getProcessMethodStr()%>
			</span>
			<%
			}
			%>
		</td>
	</tr>
	<tr>
		<td class="td1" colspan="2"><span style="margin-left: 30px; font-weight: bold">作业部（业务中心）：</span> <span><%=problem.getDepartment1Name()%></span>
			<span style="margin-left: 30px; font-weight: bold">装置：</span> <span><%=problem.getEquipmentName()%></span>
			<span style="margin-left: 30px; font-weight: bold">其他报告类型：</span> <span><%=problem.getDefectType()%></span>
		</td>
	</tr>
	<tr>
			<td class="td1" width="60%">			
				<span style="margin-left: 30px; font-weight: bold">其他报告名称：</span>  <br/>
				<span style="margin-left: 30px; ">
						<textarea readonly="readonly" rows="3" style="width:90%;" id="problemTitle"><%=problem.getProblemTitle()%></textarea>	
				</span>	
			</td>
			<td class="td1" width="640%">
				<span style="margin-left: 30px; font-weight: bold">其他报告发生时间：</span><%=Util.formatDate(problem.getDefectTime()) %>
			</td>
	</tr>	
	<tr>
		<td class="td1" colspan="2"><span
			style="margin-left: 30px; font-weight: bold">其他报告经过：</span> <br/>
			<span style="margin-left: 30px; ">
			<textarea readonly="readonly" rows="5" style="width:90%;" id="problemContent"><%=problem.getProblemContent()%></textarea>	
			</span>
		</td>
	</tr>
	<tr>
		<td class="td1" colspan="2"><span
			style="margin-left: 30px; font-weight: bold">直接经济损失与间接经济损失：
			</span> 
			<br/>
			<span style="margin-left: 30px; ">
			<textarea readonly="readonly" rows="5" style="width:90%;" id="loss"><%=problem.getLoss()%></textarea>	
			</span>
		</td>
	</tr>
	<tr>
		<td class="td1" colspan="2"><span
			style="margin-left: 30px; font-weight: bold">其他报告原因：
			</span> 
			<br/>
			<span style="margin-left: 30px; ">
			<textarea readonly="readonly"rows="10" style="width:90%;" id="reason"><%=problem.getReason()%></textarea>	
			</span>
		</td>
	</tr>
	<tr>
		<td class="td1" colspan="2"><span
			style="margin-left: 30px; font-weight: bold">其他报告教训及防范措施：
			</span> 
			<br/>
			<span style="margin-left: 30px; ">
			<textarea readonly="readonly"rows="10" style="width:90%;" id="zhenggai_cuoshi"><%=problem.getProblemZhenggai()%></textarea>	
			</span>
		</td>
	</tr>
	<tr>
		<td class="td1" colspan="2"><span
			style="margin-left: 30px; font-weight: bold">其他报告责任分析及处理情况：
			</span> 
			<br/>
			<span style="margin-left: 30px; ">
			<textarea readonly="readonly"rows="10" style="width:90%;" id="duty"><%=Util.isNullOrEmpty(problem.getDuty())?"":problem.getDuty()%></textarea>	
			</span>
		</td>
	</tr>
	<tr>
		<td class="td1" colspan="2"><span
			style="margin-left: 30px; font-weight: bold">其他报告调查小组人员名单：
			</span> 
			<br/>
			<span style="margin-left: 30px; ">
			<textarea readonly="readonly"rows="5" style="width:90%;" id="team"><%=Util.isNullOrEmpty(problem.getTeam())?"":problem.getTeam()%></textarea>	
			</span>
		</td>
	</tr>
		<tr>
			<td class="td1" colspan="2">
				<span style="margin-left: 30px" class="span1">填报人及时间：</span>
				<span><%=user.getDepartment1Name()%>-<%=user.getDepartment2Name()%>-<%=user.getDepartment3Name()%></span>
				<span><%=user.getName()%></span>
				<span><%=Util.formatDateTime(problem.getDefectWriteTime())%></span>
			</td>
		</tr>
		<tr>
			<td class="td1" align="center" colspan="2">
				<input type="button" value="关 闭" style="margin-left: 20px" onclick="closeRead()" />
			</td>
		</tr>
	</table>
</div>
<div id="selectDepart1Div" style="display: block;">
<%@include file="/other/select_depart1ID_section.jsp" %>
</div>
<script type="text/javascript">
var defectTypes = new Array();
<%
for (DefectType type : defectTypeList) {
%>
defectTypes.push("<%=type.getId()%>_<%=type.getDepartment1ID()%>");
<%
}
%>

function closeRead() {
	loadPageSection('<%=backPage%>', 'mainContentDiv', {fromPage: 'feedback'}, true);
}
</script>
